﻿using Shop.RemoteModel.Goods;
using Shop.RemoteModel.Goods.Model;
using Shop.RemoteModel.SpuGoods.Model;
using Shop.RemoteModel.SpuGoods;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Service
{
    internal class GoodsService : IGoodsService
    {
        public GoodsDetailed GetDetailed ( long id )
        {
            return new GetGoodsDetailed
            {
                Id = id
            }.Send();
        }
        public SpuDatum[] GetTops ( TopGetArg arg )
        {
            return new GetTopGoods
            {
                Param = arg
            }.Send();
        }
        public GoodsStock[] GetStocks ( long goodsId )
        {
            return new GetGoodsStock
            {
                GoodsId = goodsId
            }.Send();
        }
        public long Add ( GoodsSet datum )
        {
            return new AddGoods
            {
                Datum = datum
            }.Send();
        }
        public bool Set ( long id, GoodsSet datum )
        {
            return new SetGoods
            {
                Datum = datum,
                Id = id
            }.Send();
        }
        public void Delete ( long id )
        {
            new DeleteGoods
            {
                Id = id
            }.Send();
        }
        public GoodsDatum Get ( long id )
        {
            return new GetGoods
            {
                Id = id
            }.Send();
        }
        public void Offshelf ( long id )
        {
            new OffshelfGoods
            {
                Id = id
            }.Send();
        }
        public void Public ( long id, long userId, Dictionary<long, int> stock )
        {
            new PublicGoods
            {
                Id = id,
                OpUserId = userId,
                StockNum = stock
            }.Send();
        }
        public GoodsDto[] Gets ( long[] ids )
        {
            return new GetGoodsList
            {
                Ids = ids
            }.Send();
        }
        public PagingResult<GoodsDto> Query ( PagingParam<GoodsQueryParam> query )
        {
            return new QueryGoods
            {
                QueryParam = query.Query,
                Index = query.Index,
                IsDesc = query.IsDesc,
                NextId = query.NextId,
                Size = query.Size,
                SortName = query.SortName
            }.Send();
        }
    }
}
